package com.easylinkin.linkappapi.event;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * 事件广播器
 * <br>
 *
 * @author OuYangGuoDong
 * @version [版本号, 2017年7月14日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Component
@Lazy(value = false)
public class EventMulticaster {
    static Logger LOGGER = LoggerFactory.getLogger(EventMulticaster.class);

    private static ApplicationEventPublisher publisher;

    @Autowired
    public void setPublisher(ApplicationEventPublisher publisher) {
        EventMulticaster.publisher = publisher;
    }

    /**
     * 发布事件
     *
     * @param event
     */
    public static void publishEvent(ApplicationEvent event) {
        publisher.publishEvent(event);
    }

}
